#ifndef _MPP_DISPLAY_BUFFER_H_
#define _MPP_DISPLAY_BUFFER_H_


#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdint.h>
#include "bo.h"


#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif




class mpp_display_buffer
{
    public:
        
        mpp_display_buffer(int fd, uint32_t width, uint32_t height,
                                            uint32_t format, uint32_t flags);
        mpp_display_buffer(int fd, int prime_fd, uint32_t width, uint32_t height,
                                            uint32_t format, uint32_t flags);                                    
        bool mpp_is_exist();
        uint32_t mpp_buffer_get_id();
        void* mpp_buffer_get_addr();
        void mpp_fill_bo(uint8_t a, uint8_t r, uint8_t g, uint8_t b);


        ~mpp_display_buffer();
        
    private:
        int mpp_add_fb_sp_bo();
        int mpp_map_sp_bo();
        void mpp_free_sp_bo();
        void mpp_draw_rect(uint32_t x, uint32_t y, uint32_t width,
                                            uint32_t height, uint8_t a, uint8_t r, uint8_t g, uint8_t b);

         friend class mpp_showing;     //--定义友元类                                   
        
    protected:
        

        int fd;

        uint32_t handle;          //--申请的句柄

        uint32_t width;             //--宽度；
        uint32_t height;            //--高度；


        uint32_t virtual_height;  // 抽象高度

       uint32_t format;             //--格式
       uint32_t depth;              //--像素深度
       uint32_t bpp ;                //--像素长度

       uint32_t pitch;               //--一行宽度的总长 

        uint32_t flags;               //--buffer标志位

        uint32_t fb_id;              //--buffer ID

        uint32_t  size;              //--长度
        void      *map_addr;     // --内存镜像

};




#endif 
